#include <iostream>
#include <thread>
using namespace std;

void foo(int &num)
{
    num++;
}
int main()
{
    int num{1};
    // 1、引用多线程传参
    thread t1(foo, std::ref(num));
    // 2、使用lambda函数传参
    thread t2([&]()
              { foo(num); });
    t1.join();
    t2.join();
    cout << "num is " << num << endl;
    return 0;
}